/** bcmi_frame main scheduler
 *
 *  bcmi_frame main scheduler
 *
 *  @author : huicong
 *  @date : 2008-10-29
 *
 */

#ifndef _PARALLEL_FRAME_H
#define _PARALLEL_FRAME_H

#include "BasicHeader.h"

#include "BCMI_Frame.h"
#include "FrameClock.h"
#include "LogRecorder.h"
#include "JobSystem.h"

namespace bcmi_frame
{

    /** //UNDO
     *
     *
     *
     */
    class ParallelFrame
    {
    public:

        /** Initialize by main(argc, argv)*/
       ParallelFrame(INOUT INT argc, INOUT CHAR** argv);

       ~ParallelFrame();

    public:

        /** MAIN FUNCTION */
        HRESULT execute();

        /** return _frameLogRecorder */
        LogRecorder *getLogRecorder();

        /** return _frameClock's system time */
        INT64 getSystemTime();

        /** return _frameClock's mpi time */
        DOUBLE getMPITime();

        /** return _mpiMyProcessId */
        INT getMPIProcessId();

        INT getMPIProcessNumber();

        /** set the bufferPool size of MPIReader & MPIWriter : must before running*/
        VOID setMPITransferBufferPoolSize(IN UINT _size);

        /** set the bufferPool number of MPIReader & MPIWriter : must before running */
        VOID setMPITransferBufferPoolNumber(IN UINT _number);

        UINT getMPITransferBufferPoolSize();

        UINT getMPITransferBufferPoolNumber();

        JobSystem* getJobSystem();

    private:
        JobSystem *_frameJobSystem;
        FrameClock *_frameClock;
        LogRecorder *_frameLogRecorder;

        INT _mpiMyProcessId; // MPI_Comm_rank and MPI_COMM_WORLD
        INT _mpiProcessNumber;

        UINT _mpiTransferBufferPoolSize;
        UINT _mpiTransferBufferPoolNumber;

        BOOL _executeFlag; // test if frame is running
    };

}; //namespace bcmi_frame

#endif //#ifndef _PARALLEL_FRAME_H
